package com.example.sofa_module.sofa.fragments.pics;

import com.example.common.entity.BaseEntity;
import com.example.common.mvvm.model.BaseRespository;
import com.example.sofa_module.sofa.entity.InvitationEntity;
import com.example.sofa_module.sofa.entity.like.LikeEntity;

import io.reactivex.Observable;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class ChildModel extends BaseRespository {

    //获取帖子列表
    Observable<BaseEntity> requestInvitationList(){
        Retrofit retrofit=new Retrofit.Builder()
                .client(new OkHttpClient.Builder()
                        .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                        .build())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl("http://118.195.161.134:8088/")
                .build();
        Observable<InvitationEntity> invitationEntityObservable = retrofit.create(ApiService.class).requestSofaPics();
        return checkNetWork(invitationEntityObservable);
    }

    //点赞
    Observable<BaseEntity> requestLike(int commentId,int userId){
        Retrofit retrofit=new Retrofit.Builder()
                .client(new OkHttpClient.Builder()
                        .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                        .build())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl("http://118.195.161.134:8088/")
                .build();
        Observable<LikeEntity> likeEntityObservable = retrofit.create(ApiService.class).requestSofaLike(commentId,userId);
        return checkNetWork(likeEntityObservable);
    }




}
